<form method="post" action="<?php echo admin_page_url(PRODUCT_SLUG . '/' . UPDATE_SLUG); ?>" data-callback="1">
    <div class="row">
        <h1 class="col-md-9">Quản lý sản phẩm <small>Quản lý các sản phẩm</small></h1>
        <h1 class="col-md-3">
            <a class="btn btn-default pull-right mgl5" href="<?php echo admin_page_url(PRODUCT_SLUG); ?>"><i class="fa fa-external-link"></i> Trở về</a>
            <button type="button" class="btn btn-success btn-submit-update pull-right mgl5"><i class="fa fa-check-square-o"></i> Cập nhật</button>
            <a target="_blank" class="btn btn-success pull-right" href="<?php echo product_url($product->product_slug); ?>"><i class="fa fa-external-link"></i> Xem</a>
        </h1>
        <div class="col-md-12">
            <ol class="breadcrumb">
                <li><a href="<?php echo admin_page_url(); ?>"><i class="fa fa-dashboard"></i> Dashboard</a></li>
                <li><a href="<?php echo admin_page_url(PRODUCT_SLUG); ?>"><i class="fa fa-table"></i> Sản phẩm</a></li>
                <li class="active"><i class="fa fa-table"></i> <?php echo $product->product_title; ?></li>
            </ol>
        </div>
        <div class="clearfix"></div>
    </div>

    <div class='row'>
        <div class="form-group col-md-9 col-xs-12">
            <label for="input-product-title">Tên</label>
            <input type="text" class="form-control auto-slug" follow-ctr="#input-product-slug" id="input-product-title" name="product[title]" value="<?php echo $product->product_title; ?>" />
            <input type="hidden" name="product[id]" value="<?php echo $this->encrypt->encode($product->product_id); ?>" />
            <input type="hidden" name="product[shop_id]" value="<?php echo $this->encrypt->encode($product->product_shop_id); ?>" />
        </div>

        <div class="form-group col-md-9 col-xs-12">
            <label for="input-product-slug">Đường dẫn</label>
            <input type="text" class="form-control" id="input-product-slug" name="product[slug]" value="<?php echo $product->product_slug; ?>"/>
        </div>
        <div class="clearfix"></div>

        <div class="form-group col-md-3 col-xs-12">
            <label for="input-product-cate">Danh mục</label>
            <select disabled="disabled" id="input-product-cate" class="form-control">
                <?php foreach($aProductCate as $cate) {?>
                <option <?php echo $cate->getId()==$product->product_cate_id?'selected="selected"':''; ?>>
                    <?php echo $cate->getTitle(); ?>
                </option>
                <?php } ?>
            </select>
        </div>
        <div class="form-group col-md-2 col-xs-12">
            <div class="checkbox ">
            <label><br />
                <input type="checkbox" id="input-product-active-flg" name="product[active_flg]"
                    value="1" <?php echo $product->product_active_flg==1?'checked="checked"':''; ?> />
                Hiển thị
            </label>
            </div>
        </div>
        <div class="form-group col-md-2 col-xs-12">
            <div class="checkbox ">
            <label><br />
                <input type="checkbox" id="input-product-delete-flg" name="product[delete_flg]"
                    value="1" <?php echo $product->product_deleted_at!=NULL?'checked="checked"':''; ?> />
                Xoá
            </label>
            </div>
        </div>
        <div class="clearfix"></div>

        <div class="col-md-12">
            <div class="table-responsive">
                <table id="product-in-set-list" class="table table-bordered table-hover tablesorter item-list">
                    <thead>
                        <tr>
                            <th class="header"># <i class="fa fa-sort"></i></th>
                            <th class="header">&nbsp;</th>
                            <th class="header">Sản phẩm</th>
                            <th class="header">Mô tả</th>
                            <th class="header">&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach($aProductInSet as $index=>$pis) { ?>
                        <tr class="">
                            <th><?php echo $index+1; ?></th>
                            <td class="col-md-1 col-xs-4">
                                <div class="media">
                                    <?php $pImageThumb = product_upload($pis->getImage(), $product->shop_image_folder); ?>
                                    <?php $pImage      = product_upload($pis->getImage(), $product->shop_image_folder, false); ?>
                                    <a title="<?php echo $pis->getCode(); ?>" class="product-detail-img thumbnail fancybox" rel="group" href="<?php echo $pImage; ?>">
                                    <?php if($pis->getImage()!='') { ?>
                                        <img class="media-object" src="<?php echo $pImageThumb; ?>" />
                                    <?php } else { ?>
                                        <img data-src="holder.js/100%x180" class="media-object" />
                                        <?php } ?>
                                    </a>
                                </div>
                            </td>
                            <td class="col-md-2 col-xs-5">
                                <label class="normal">
                                    Mã sản phẩm
                                    <input type="text" class="form-control" id="input-product-detail-code"
                                        name="product_detail[<?php echo $index+1; ?>][code]" value="<?php echo $pis->getCode(); ?>"/>
                                </label>
                                <br />
                                <label class="normal">
                                    Giá cũ
                                    <input type="text" class="form-control" id="input-product-detail-price-old"
                                        name="product_detail[<?php echo $index+1; ?>][price_old]" value="<?php echo $pis->getPriceOld(); ?>"/>
                                </label>
                                <br />
                                <label class="normal">
                                    Giá mới
                                    <input type="text" class="form-control" id="input-product-detail-price-new"
                                        name="product_detail[<?php echo $index+1; ?>][price_new]" value="<?php echo $pis->getPriceNew(); ?>"/>
                                </label>
                            </td>
                            <td>
                                <textarea id="input-product-detail-description" name="product_detail[<?php echo $index+1; ?>][description]" class="form-control" rows="5"><?php echo $pis->getDescription(); ?></textarea>
                            </td>
                            <td class="col-md-2 col-xs-4">
                                <label class="normal">
                                    <input type="checkbox" class="input-product-detail-is-avatar" name="product_detail[<?php echo $index+1; ?>][is_avatar]" value="1"
                                       <?php if($pis->getIsAvatar()==1) { ?> checked="checked" <?php } ?> />
                                    Sản phẩm chính
                                </label>
                                <br />
                                <label class="normal">
                                    <input type="checkbox" class="input-product-detail-delete-flg" name="product_detail[<?php echo $index+1; ?>][delete_flg]" value="1"
                                        <?php if($pis->getDeletedAt()!=NULL) { ?> checked="checked" <?php } ?> />
                                    Xoá
                                </label>
                                <input type="hidden" name="product_detail[<?php echo $index+1; ?>][id]" value="<?php echo $this->encrypt->encode($pis->getId()); ?>" />
                            </td>
                        </tr>
                        <?php } ?>
                    </tbody>
                </table>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
</form>